<template>
	<div>
		<Menu/>
		<Head/>
		<div class="company_main">
			<el-button type="primary" @click="handleAddStock()">新 增</el-button><el-button type="primary" @click="handleUpdate()">更 新</el-button>
			<div> &nbsp; </div>
			<el-table 
				:data="company_list"        
				empty-text="暂无数据"
				:header-cell-style="{ 'text-align': 'left', 'height':'20px'}"
				:cell-style="{'text-align': 'left'}"
			>
				<el-table-column prop="Sid" label="ID" fixed="left" width="60"></el-table-column>
				<el-table-column prop="Stock_name" label="证券名称" width="100" align="center"></el-table-column>
				<el-table-column prop="Stock_code" label="证券编码" width="100"></el-table-column>
				<el-table-column prop="Institutions_name" label="单位名称" width="450"> </el-table-column>
				<el-table-column prop="Institutions_industry" label="所属行业" width="200"> </el-table-column>
				<el-table-column prop="Region" label="区域" width="60"> </el-table-column>
				<el-table-column prop="Jys" label="交易所" width="80"> </el-table-column>
				<el-table-column label="操作">    
					<template #default="scope">
						<el-button type="primary" @click="handleStock(scope.$index, scope.row)">证券</el-button>
						<el-button type="primary" @click="handleUpdate(scope.$index, scope.row)">更新</el-button>
						<el-button type="primary" @click="handleDetail(scope.$index, scope.row)">详情</el-button>
						<el-button type="primary" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
						<el-button type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
					  </template>
				</el-table-column>
			</el-table>
		</div>
	</div>
</template>

<script>
	import Menu from '../../components/Menu.vue'
	import Head from '../../components/Head.vue'
	export default {
		name:"CompanyListView",
		components:{
			Menu,
			Head,
		},
		data(){
			return {
				company_list:[]
			}
		},
		methods:{
			getCompanyList(){
				var thisInfo = this
				this.$axios.post('/api/v1/company/company_list', {}, {headers:{'Content-Type':'"application/x-www-form-urlencoded;charset=UTF-8'}}).then(function (response) {
					thisInfo.company_list = response.data.data.list
				});
			},
			handleStock(i, r){
				this.$router.push('/stock/'+r.Sid)
			},
			handleDetail(i, r){
				this.$router.push('/company_detail/'+r.Sid)
			},
			handleUpdate(i, r){
				this.$axios.post('/api/v1/company/company_add', {'stock':r.Stock_code,'jys':r.Jys}, {headers:{'Content-Type':'multipart/form-data; charset=utf-8', 'Accept':'*/*','Connection':'keep-alive'}}).then(function (response) {
					alert(response.data.data);
				});
			},
			handleEdit(i, r){
				this.$router.push('/company_edit/'+r.Sid)
			},
			handleAddStock(){
				this.$router.push('/company_add')
			},
			handleDelete(i, r){
				console.log('1111111111111')
			}
		},
		mounted: function(){
			this.getCompanyList();
		}
	}
</script>
<style scoped>
	.company_main{
		width: 86%;
		height: 100%;
		/* background: goldenrod; */
		float: left; 
		margin-top: 0.4%;
		margin-left: 0.6%;
	}
	
	.tableRowClassName .warning-row{
		background: red;
	}
</style>